<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <input type="text" class="user">
    <input type="text" class="pwd">
    <button>注册</button>


    <script src="../js/promise_ajax.js"></script>
    <script src="../js/api_v2.js"></script>
    <script>

        const oUser = document.querySelector('.user');
        const oPwd = document.querySelector('.pwd');
        const oBtn = document.querySelector('button');
        oBtn.addEventListener('click', function () {
            const username = oUser.value;
            const password = oPwd.value;
            reg({
                username,
                password
            }).then(res => {
                console.log(res);
                const { status, msg } = res;
                if (status) {
                    // 跳转至登录
                } else {
                    alert(msg);

                }
            })
        })

    </script>

</body>

</html>